package c.e.a.b.e.c;

import com.huawei.hms.analytics.core.crypto.AesCipher.AesLen;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
public abstract class e4 extends u3 {
    public static final Logger b = Logger.getLogger(e4.class.getName());
    public static final boolean c = l7.g;
    public g4 a = this;

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static class a extends IOException {
        public a(Throwable th) {
            super("CodedOutputStream was writing to a flat byte array and ran out of space.", th);
        }

        public a(String str, Throwable th) {
            str = String.valueOf(str);
            String str2 = "CodedOutputStream was writing to a flat byte array and ran out of space.: ";
            super(str.length() != 0 ? str2.concat(str) : new String(str2), th);
        }
    }

    /* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
    public static class b extends e4 {
        public final byte[] d;
        public final int e;
        public int f;

        public b(byte[] bArr, int i) {
            super(null);
            if (((i | 0) | (bArr.length - i)) >= 0) {
                this.d = bArr;
                this.f = 0;
                this.e = i;
                return;
            }
            throw new IllegalArgumentException(String.format("Array range is invalid. Buffer.length=%d, offset=%d, length=%d", new Object[]{Integer.valueOf(bArr.length), Integer.valueOf(0), Integer.valueOf(i)}));
        }

        public final void A(long j) throws IOException {
            try {
                byte[] bArr = this.d;
                int i = this.f;
                int i2 = i + 1;
                this.f = i2;
                bArr[i] = (byte) ((int) j);
                i = i2 + 1;
                this.f = i;
                bArr[i2] = (byte) ((int) (j >> 8));
                i2 = i + 1;
                this.f = i2;
                bArr[i] = (byte) ((int) (j >> 16));
                i = i2 + 1;
                this.f = i;
                bArr[i2] = (byte) ((int) (j >> 24));
                i2 = i + 1;
                this.f = i2;
                bArr[i] = (byte) ((int) (j >> 32));
                i = i2 + 1;
                this.f = i;
                bArr[i2] = (byte) ((int) (j >> 40));
                i2 = i + 1;
                this.f = i2;
                bArr[i] = (byte) ((int) (j >> 48));
                this.f = i2 + 1;
                bArr[i2] = (byte) ((int) (j >> 56));
            } catch (IndexOutOfBoundsException e) {
                throw new a(String.format("Pos: %d, limit: %d, len: %d", new Object[]{Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(1)}), e);
            }
        }

        public final void C(int i) throws IOException {
            try {
                byte[] bArr = this.d;
                int i2 = this.f;
                int i3 = i2 + 1;
                this.f = i3;
                bArr[i2] = (byte) i;
                i2 = i3 + 1;
                this.f = i2;
                bArr[i3] = (byte) (i >> 8);
                i3 = i2 + 1;
                this.f = i3;
                bArr[i2] = (byte) (i >> 16);
                this.f = i3 + 1;
                bArr[i3] = (byte) (i >>> 24);
            } catch (IndexOutOfBoundsException e) {
                throw new a(String.format("Pos: %d, limit: %d, len: %d", new Object[]{Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(1)}), e);
            }
        }

        public final void G(int i, int i2) throws IOException {
            r((i << 3) | 5);
            C(i2);
        }

        public final void W(t3 t3Var) throws IOException {
            r(t3Var.c());
            t3Var.h(this);
        }

        public final void X(e6 e6Var) throws IOException {
            r(e6Var.b());
            e6Var.e(this);
        }

        public final void Y(String str) throws IOException {
            int i = this.f;
            try {
                int L = e4.L(str.length() * 3);
                int L2 = e4.L(str.length());
                if (L2 == L) {
                    L = i + L2;
                    this.f = L;
                    L = m7.a.b(str, this.d, L, a());
                    this.f = i;
                    r((L - i) - L2);
                    this.f = L;
                    return;
                }
                r(m7.a(str));
                this.f = m7.a.b(str, this.d, this.f, a());
            } catch (q7 e) {
                Throwable th = e;
                this.f = i;
                e4.b.logp(Level.WARNING, "com.google.protobuf.CodedOutputStream", "inefficientWriteStringNoTag", "Converting ill-formed UTF-16. Your Protocol Buffer will not round trip correctly!", th);
                byte[] bytes = str.getBytes(w4.a);
                try {
                    r(bytes.length);
                    Z(bytes, 0, bytes.length);
                } catch (IndexOutOfBoundsException e2) {
                    throw new a(e2);
                } catch (a e3) {
                    throw e3;
                }
            } catch (IndexOutOfBoundsException e22) {
                throw new a(e22);
            }
        }

        public final void Z(byte[] bArr, int i, int i2) throws IOException {
            try {
                System.arraycopy(bArr, i, this.d, this.f, i2);
                this.f += i2;
            } catch (IndexOutOfBoundsException e) {
                throw new a(String.format("Pos: %d, limit: %d, len: %d", new Object[]{Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(i2)}), e);
            }
        }

        public final int a() {
            return this.e - this.f;
        }

        public final void d(byte b) throws IOException {
            try {
                byte[] bArr = this.d;
                int i = this.f;
                this.f = i + 1;
                bArr[i] = b;
            } catch (IndexOutOfBoundsException e) {
                throw new a(String.format("Pos: %d, limit: %d, len: %d", new Object[]{Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(1)}), e);
            }
        }

        public final void e(int i) throws IOException {
            if (i >= 0) {
                r(i);
            } else {
                m((long) i);
            }
        }

        public final void f(int i, int i2) throws IOException {
            r((i << 3) | i2);
        }

        public final void g(int i, long j) throws IOException {
            r((i << 3) | 0);
            m(j);
        }

        public final void h(int i, t3 t3Var) throws IOException {
            r((i << 3) | 2);
            W(t3Var);
        }

        public final void i(int i, e6 e6Var) throws IOException {
            f(1, 3);
            y(2, i);
            f(3, 2);
            X(e6Var);
            f(1, 4);
        }

        public final void j(int i, e6 e6Var, s6 s6Var) throws IOException {
            r((i << 3) | 2);
            l3 l3Var = (l3) e6Var;
            int j = l3Var.j();
            if (j == -1) {
                j = s6Var.e(l3Var);
                l3Var.k(j);
            }
            r(j);
            s6Var.f(e6Var, this.a);
        }

        public final void k(int i, String str) throws IOException {
            r((i << 3) | 2);
            Y(str);
        }

        public final void l(int i, boolean z) throws IOException {
            r((i << 3) | 0);
            d((byte) z);
        }

        public final void m(long j) throws IOException {
            byte[] bArr;
            int i;
            int i2;
            if (!e4.c || a() < 10) {
                while ((j & -128) != 0) {
                    bArr = this.d;
                    i = this.f;
                    this.f = i + 1;
                    bArr[i] = (byte) ((((int) j) & 127) | AesLen.ROOTKEY_COMPONET_LEN);
                    j >>>= 7;
                }
                try {
                    bArr = this.d;
                    i2 = this.f;
                    this.f = i2 + 1;
                    bArr[i2] = (byte) ((int) j);
                    return;
                } catch (IndexOutOfBoundsException e) {
                    throw new a(String.format("Pos: %d, limit: %d, len: %d", new Object[]{Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(1)}), e);
                }
            }
            while ((j & -128) != 0) {
                bArr = this.d;
                i = this.f;
                this.f = i + 1;
                l7.g(bArr, (long) i, (byte) ((((int) j) & 127) | AesLen.ROOTKEY_COMPONET_LEN));
                j >>>= 7;
            }
            bArr = this.d;
            i2 = this.f;
            this.f = i2 + 1;
            l7.g(bArr, (long) i2, (byte) ((int) j));
        }

        public final void r(int i) throws IOException {
            byte[] bArr;
            int i2;
            if (!e4.c || q3.a() || a() < 5) {
                while ((i & -128) != 0) {
                    bArr = this.d;
                    i2 = this.f;
                    this.f = i2 + 1;
                    bArr[i2] = (byte) ((i & 127) | AesLen.ROOTKEY_COMPONET_LEN);
                    i >>>= 7;
                }
                try {
                    bArr = this.d;
                    i2 = this.f;
                    this.f = i2 + 1;
                    bArr[i2] = (byte) i;
                } catch (IndexOutOfBoundsException e) {
                    throw new a(String.format("Pos: %d, limit: %d, len: %d", new Object[]{Integer.valueOf(this.f), Integer.valueOf(this.e), Integer.valueOf(1)}), e);
                }
            } else if ((i & -128) == 0) {
                bArr = this.d;
                i2 = this.f;
                this.f = i2 + 1;
                l7.g(bArr, (long) i2, (byte) i);
            } else {
                bArr = this.d;
                i2 = this.f;
                this.f = i2 + 1;
                l7.g(bArr, (long) i2, (byte) (i | AesLen.ROOTKEY_COMPONET_LEN));
                i >>>= 7;
                if ((i & -128) == 0) {
                    bArr = this.d;
                    i2 = this.f;
                    this.f = i2 + 1;
                    l7.g(bArr, (long) i2, (byte) i);
                    return;
                }
                bArr = this.d;
                i2 = this.f;
                this.f = i2 + 1;
                l7.g(bArr, (long) i2, (byte) (i | AesLen.ROOTKEY_COMPONET_LEN));
                i >>>= 7;
                if ((i & -128) == 0) {
                    bArr = this.d;
                    i2 = this.f;
                    this.f = i2 + 1;
                    l7.g(bArr, (long) i2, (byte) i);
                    return;
                }
                bArr = this.d;
                i2 = this.f;
                this.f = i2 + 1;
                l7.g(bArr, (long) i2, (byte) (i | AesLen.ROOTKEY_COMPONET_LEN));
                i >>>= 7;
                if ((i & -128) == 0) {
                    bArr = this.d;
                    i2 = this.f;
                    this.f = i2 + 1;
                    l7.g(bArr, (long) i2, (byte) i);
                    return;
                }
                bArr = this.d;
                i2 = this.f;
                this.f = i2 + 1;
                l7.g(bArr, (long) i2, (byte) (i | AesLen.ROOTKEY_COMPONET_LEN));
                i >>>= 7;
                bArr = this.d;
                i2 = this.f;
                this.f = i2 + 1;
                l7.g(bArr, (long) i2, (byte) i);
            }
        }

        public final void s(int i, int i2) throws IOException {
            r((i << 3) | 0);
            if (i2 >= 0) {
                r(i2);
            } else {
                m((long) i2);
            }
        }

        public final void t(int i, t3 t3Var) throws IOException {
            f(1, 3);
            y(2, i);
            h(3, t3Var);
            f(1, 4);
        }

        public final void y(int i, int i2) throws IOException {
            r((i << 3) | 0);
            r(i2);
        }

        public final void z(int i, long j) throws IOException {
            r((i << 3) | 1);
            A(j);
        }
    }

    public static int B(int i, long j) {
        return F(j) + L(i << 3);
    }

    public static int D(int i) {
        return L(i << 3);
    }

    public static int E(int i, long j) {
        return F(j) + L(i << 3);
    }

    public static int F(long j) {
        if ((-128 & j) == 0) {
            return 1;
        }
        if (j < 0) {
            return 10;
        }
        int i;
        if ((-34359738368L & j) != 0) {
            i = 6;
            j >>>= 28;
        } else {
            i = 2;
        }
        if ((-2097152 & j) != 0) {
            i += 2;
            j >>>= 14;
        }
        if ((j & -16384) != 0) {
            i++;
        }
        return i;
    }

    public static int H(int i) {
        return i >= 0 ? L(i) : 10;
    }

    public static int I(int i, int i2) {
        return H(i2) + L(i << 3);
    }

    public static int J(int i, long j) {
        return F(R(j)) + L(i << 3);
    }

    public static int K(long j) {
        return F(R(j));
    }

    public static int L(int i) {
        return (i & -128) == 0 ? 1 : (i & -16384) == 0 ? 2 : (-2097152 & i) == 0 ? 3 : (i & -268435456) == 0 ? 4 : 5;
    }

    public static int M(int i, int i2) {
        return L(i2) + L(i << 3);
    }

    public static int N(int i) {
        return L(i << 3) + 8;
    }

    public static int O(int i) {
        return L(V(i));
    }

    public static int P(int i, int i2) {
        return L(V(i2)) + L(i << 3);
    }

    public static int Q(int i) {
        return L(i << 3) + 8;
    }

    public static long R(long j) {
        return (j >> 63) ^ (j << 1);
    }

    public static int S(int i) {
        return L(i << 3) + 4;
    }

    public static int T(int i) {
        return L(i << 3) + 4;
    }

    public static int U(int i, int i2) {
        return H(i2) + L(i << 3);
    }

    public static int V(int i) {
        return (i >> 31) ^ (i << 1);
    }

    public static int b(j5 j5Var) {
        int a = j5Var.a();
        return L(a) + a;
    }

    public static int c(e6 e6Var, s6 s6Var) {
        l3 l3Var = (l3) e6Var;
        int j = l3Var.j();
        if (j == -1) {
            j = s6Var.e(l3Var);
            l3Var.k(j);
        }
        return L(j) + j;
    }

    public static int n(int i) {
        return L(i << 3) + 4;
    }

    public static int o(int i, String str) {
        return q(str) + L(i << 3);
    }

    public static int p(t3 t3Var) {
        int c = t3Var.c();
        return L(c) + c;
    }

    public static int q(String str) {
        int a;
        try {
            a = m7.a(str);
        } catch (q7 unused) {
            a = str.getBytes(w4.a).length;
        }
        return L(a) + a;
    }

    public static int u(int i) {
        return L(i << 3) + 8;
    }

    public static int v(int i) {
        return L(i << 3) + 1;
    }

    public static int w(int i, t3 t3Var) {
        i = L(i << 3);
        int c = t3Var.c();
        return (L(c) + c) + i;
    }

    @Deprecated
    public static int x(int i, e6 e6Var, s6 s6Var) {
        i = L(i << 3) << 1;
        l3 l3Var = (l3) e6Var;
        int j = l3Var.j();
        if (j == -1) {
            j = s6Var.e(l3Var);
            l3Var.k(j);
        }
        return i + j;
    }

    public abstract void A(long j) throws IOException;

    public abstract void C(int i) throws IOException;

    public abstract void G(int i, int i2) throws IOException;

    public abstract int a();

    public abstract void d(byte b) throws IOException;

    public abstract void e(int i) throws IOException;

    public abstract void f(int i, int i2) throws IOException;

    public abstract void g(int i, long j) throws IOException;

    public abstract void h(int i, t3 t3Var) throws IOException;

    public abstract void i(int i, e6 e6Var) throws IOException;

    public abstract void j(int i, e6 e6Var, s6 s6Var) throws IOException;

    public abstract void k(int i, String str) throws IOException;

    public abstract void l(int i, boolean z) throws IOException;

    public abstract void m(long j) throws IOException;

    public abstract void r(int i) throws IOException;

    public abstract void s(int i, int i2) throws IOException;

    public abstract void t(int i, t3 t3Var) throws IOException;

    public abstract void y(int i, int i2) throws IOException;

    public abstract void z(int i, long j) throws IOException;

    public e4(d4 d4Var) {
    }
}
